<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<%@ page pageEncoding="UTF-8" %>
<%@ include file="../common/common.jsp"%>
<%@ page import="jp.co.technotree.apl.api.common.Message" %>
<%@page import="jp.co.technotree.apl.api.common.FwCom"%>
<%@page import="jp.co.technotree.apl.cmd.use.Use2000Bean"%>
<jsp:useBean id="formBean" class="jp.co.technotree.apl.cmd.use.Use2000Bean" scope="request" />
<%
	String strOutputCate = formBean.getOutputCate(); //1=初回モード 2=入荷中モード 3=完了モード 4=キャンセルモード 5=参照モード

%>
<html>
	<head>
		<title>予備品管理システム - 直結看板以外余剰登録画面</title>
		<link rel="SHORTCUT ICON" href="../common/img/default/sys_icon.ico">

		<link rel='stylesheet' type='text/css' href='../../common/css/common/base.css' >
		<link rel='stylesheet' type='text/css' href='../../common/css/common/common.css'>
		<link rel='stylesheet' type='text/css' href='../../common/css/use/use3000.css'>

		<script language="javascript" src="../../common/js/base.js"></script>
		<script language="javascript" src="../../common/js/menu/topmenu.js"></script>

		<!--ポップアップ用-->
		<link rel='stylesheet' type='text/css' href='../../common/css/popUpPc.css' >
		<script type='text/javascript' src='../../common/js/popUpPc.js'></script>
		
		<!-- システムログ -->
		<script src="../../common/js/systemlog.js"></script>

			<style type='text/css'>
				.LinkItem {
					cursor: pointer;
				}
				.ReadStyle{
					 background-color:#CCC;
				}
			</style>

<script language="javascript">

//画面固定
//document.addEventListener('touchmove', function (e) { e.preventDefault(); }, false);


function onInit(){
	//入荷完了後、メッセーを出してメイン画面に遷移
	var stateFlg = "<%=formBean.getStateFlg()%>";
	var afterFunc="nextPageJump('odr6000');"
	if(stateFlg == "4"){
		//入荷取消を正常に完了しました
		alert_Info2("<%=Message.getMessage("INF00020").replace("$1", "余剰取消")%>",afterFunc);
	}
}


function nextPageJump(nextPage){
	mainForm = document.getElementById("F1");
	document.getElementById("nextPage").value = nextPage;

	mainForm.submit();
}




//パップアップ解除
function back(){
	document.getElementById("opAlertBtn").style.display = "none";
	document.getElementById("opAlert").style.display = "none";
	document.getElementById("opAlertButton").style.display = "none";
	document.getElementById("opAlertTop").style.display = "none";
	document.getElementById("allbackgr").style.display = "none";
}

//「入荷取消」ボタン押下
function undoBtn(){
	
	//確定時と入荷時の更新日を比較
	mRsvSupplyCheck();

}



function JSONConvert(node){
	var type = node.nodeType;
	if ( isTextNode(node) ){
		var text = getTextValue(node);
		return text;
	}
	if ( type==1 ){
		var json = {};
		var nodeName = node.nodeName;
		var childs = node.childNodes;

		for (var i = 0; i<childs.length; i++){
			var child = childs[i];
			var obj = json[child.nodeName];

			if ( child.nodeType == 1 ){
				if ( obj ){
					var array = null;
					if ( !isArray(obj) ){
						array=[];
						array[array.length]=obj;
					}else{
						array=json[child.nodeName];
					}
					array[array.length]=JSONConvert(child);
					json[child.nodeName]=array;
				}else{
					json[child.nodeName]=JSONConvert(child);
				}
			}
		}
		return json;
	}
}

function isTextNode(node){
	if ( node.hasChildNodes() ){
		var childs = node.childNodes;
		for (var i = 0; i<childs.length; i++){
			var child = childs[i];
			if ( child.nodeType != 3 ) return false;
		}
	}
	return true;
}

function getTextValue(node){
	if ( node.hasChildNodes() ){
		var childs = node.childNodes;
		var child = childs[0];
		if ( child.nodeType == 3 ){
			return child.nodeValue;
		}
	}
	return null;
}
//------------------------------------------------------------------------------

//*************************************************
//AJAX 部分(予備品Mから削除チェック)
//*************************************************
function mRsvSupplyCheck(){
	
	var findItemNo = document.getElementById("itemNo1").value+"-"+document.getElementById("itemNo2").value;
	
	var xmlHttp;

	xmlHttp = new XMLHttpRequest();
	xmlHttp.onreadystatechange = checkStatus2;
	xmlHttp.open("GET", "../itm2099/itm2099?itemCd="+findItemNo, false);
	xmlHttp.send(null);

	function checkStatus2(){
		if (xmlHttp.readyState == 4 && xmlHttp.status == 200){
			var xml = xmlHttp.responseXML;
			var rootNodes = xml.getElementsByTagName("list");
			var rootNode = rootNodes[0];
			var json = JSONConvert(rootNode);
			if (json==null) {
			}else {
				//-----------------------------------------
				//削除チェック
				//-----------------------------------------
				var delDiv = json.deldiv;

				//削除の時はメッセージを表示
				if(delDiv == "1"){
					alert_Custom("<%=Message.getMessage("WRN01500").replace("$1", "入荷取消")%>");
					return;
				}
				updateDtCheck3();

			}
		}
	}
}

//*************************************************
//AJAX 部分(確定時と発注時の予備品入荷Tの更新日を比較)
//*************************************************
function updateDtCheck3(){
	mainForm = document.getElementById("F1");
	//------------------------------------------------------
	//入荷Tの確定時と発注時の更新日を比較
	var findOdrNo = document.getElementById("odrNo").value;
	
	var xmlHttp;

	xmlHttp = new XMLHttpRequest();
	xmlHttp.onreadystatechange = checkStatus4;
	xmlHttp.open("GET","../inv2002/inv2002?odrNo="+findOdrNo,false);
	xmlHttp.send(null);

	function checkStatus4(){
		if (xmlHttp.readyState == 4 && xmlHttp.status == 200){
			var xml = xmlHttp.responseXML;
			var rootNodes = xml.getElementsByTagName("list");
			var rootNode = rootNodes[0];
			var json = JSONConvert(rootNode);
			if (json==null) {
			}else {
				var orderUpdateDt = json.updatedt;
				var confirmUdateDt = document.getElementById("updateDt_hid_odr").value;
				//確定時と発注時の更新日を比較
				if(orderUpdateDt == confirmUdateDt || orderUpdateDt == null){
					
					var afterFunc="yesUndoBtn();"
					if (!confirm_Custom3("<%=Message.getMessage("INF01110").replace("$1", "作業完了").replace("$2","入荷済")%>",afterFunc)){
						return;
					}
				}else{

					alert_Custom("<%=Message.getMessage("WRN01030").replace("$1", "余剰取消")%>");
					//予備品のマスタ情報が既に変更されています。発注を再度やり直して下さい。
					return;
				}

			}
		}
		//------------------------------------------------------
	}
}
//「はい」を押された時
function yesUndoBtn(){
	document.getElementById("undoExe").value = "1";
	mainForm = document.getElementById("F1");
	mainForm.submit();
}

</script>

	</head>

	<body onLoad="onInit()" style="margin: 0px 4px 0px 0px;">
		<form class="frmMain" name="main" id="F1" action="./use2000" method="post" enctype="multipart/form-data" onsubmit="return false;">
			<table class="tblMain" width="100%" cellspacing="0" cellpadding="0" border="0">
				<tr>
					<td valign="top">
						<table class='main-width-tb'  cellspacing='0' cellpadding='0' border='0'><tr><td></td></tr></table>
						<table class='main-height-tb' cellspacing='0' cellpadding='0' border='0'><tr><td></td></tr></table>

						<!-- Header Menu START -->
						<div class="header-title">予備品管理システム(<%=formBean.kojou%>)</div>
						<!-- Header Menu END -->

						<!-- ***** [FORM] MAIN-FORM ***** -->
						<div id="lc-out" style="z-index: 0;">
<%
//バックカラーの設定
String backColor="background-color:	#FFFFFF;";
if("3".equals(strOutputCate)){
	backColor="background-color:	#F0FFFF;";
}else if("4".equals(strOutputCate)){
	backColor="background-color:	#FFF0F5;";
}
%>
							<div id="lc-in" style="z-index: 0;<%=backColor%>">
<%
//題名の設定
String headSubName="仕掛中";
if("3".equals(strOutputCate)){
	headSubName = "完了";
}else if("4".equals(strOutputCate)){
	headSubName = "キャンセル";
}
%>
								<div  style="margin: 20px ; width: 98%;">
									<div class="subtitle">直結看板以外余剰登録画面（<%=headSubName%>）</div>

									<table  border="0"  width="98%">
										<tr>
											<td>
												<table border="0" style="margin-left: 30px;">

												</table>
											</td>
										</tr>
									</table>

									<!-- スペース -->
									<table height="30px" width="98%"><tr><td></td></tr></table>

									<table  border="0" width="98%">
										<tr>
											<td>
												<table border="0" style="margin-left: 30px; width: 800px;" align="left">
													<tr>
														<td style="width:10%;">
															発注方法：
														</td>
														<td>
															<input type="text" name="odrMeth" id="odrMeth" class="ReadStyle" style="width:150px;" value="<%=formBean.getOdrMethNm()%>" readonly>
														</td>
														<td></td>
														<td></td>
														<td></td>
														<td></td>
													</tr>
													<!-- スペース -->
													<tr style="height: 30px;"><td></td></tr>
													<tr>
														<td>
															Y品番：
														</td>
														<td>
															<input type="text"  class="ReadStyle" name="itemNo1" id="itemNo1" style="width: 120px;"  value="<%=formBean.getItemNo1()%>" readonly> -
															<input type="text"  class="ReadStyle" name="itemNo2" id="itemNo2" style="width: 120px;" value="<%=formBean.getItemNo2()%>"  readonly>
														</td>
														<td >
															発注日：
														</td>
														<td>
															<input type="text"  class="ReadStyle TxtCenter" name="odrDt" id="odrDt" style="width: 200px;" value="<%=formBean.getOdrDt()%>" readonly>
														</td>
													</tr>
													<!-- スペース -->
													<tr style="height: 30px;"><td></td></tr>
													<tr>
														<td>
															品　名：
														</td>
														<td colspan="5">
															<textarea  class="ReadStyle" name="" cols="40" rows="2" style="width:  600px;" readonly  ><%=formBean.getItemNm()%></textarea>
														</td>
													</tr>
													<!-- スペース -->
													<tr style="height: 30px;"><td></td></tr>
													<tr>
														<td>
															型　式：
														</td>
														<td colspan="5">
															<textarea class="ReadStyle" name="" cols="40" rows="2" style="width:  600px;"  readonly ><%=formBean.getModel()%></textarea>
														</td>
													</tr>
												</table>

												<table  border="1" style="width: 400px; height:200px; border-color: gray;" align="left">
													<tr>
														<td>
														<table  border="0" style="width: 98%; height:98%;">
															<tr>
																<td colspan="2">
																	受注理由
																</td>
															</tr>
															<tr height="10px"><td></td></tr>
															<tr>
																<td class="TxtCenter">
																	使用設備：
																</td>
																<td class="">
																	<input type="text"  class="ReadStyle" name="" id="" style="width: 250px;" readonly value="<%=formBean.getUseFacil()%>" readonly>
																</td>
															</tr>
															<tr>
																<td class="TxtCenter">
																	使用用途：
																</td>
																<td class="">
																	<input type="text"  class="ReadStyle" name="" id="" style="width: 250px;" readonly value="<%=formBean.getUseMeth()%>" readonly>
																</td>
															</tr>
															<tr>
																<td class="TxtCenter">
																	使用予定日：
																</td>
																<td class="">
																	<input type="text"  class="ReadStyle" name="" id="" style="width: 100px;" readonly value="<%=formBean.getUsePlanDt()%>" readonly>
																</td>
															</tr>
														</table>
														</td>
													</tr>
												</table>
											</td>
										</tr>
									</table>

									<!-- スペース -->
									<table height="30px" width="98%"><tr><td></td></tr></table>

									<table  border="0"  width="98%">
										<tr>
											<td>
												<table border="0" style="margin-left: 30px; width: 800px;" align="left">
													<tr>
														<td style="width:10%;">
															単　価：
														</td>
														<td>
															<input type="text"  class="ReadStyle TxtRight" name="" id="" style="width: 120px;" readonly  value="<%=formBean.getUnitPrice()%>">
														</td>
														<td style="width:12%;">
															L/T：
														</td>
														<td>
															<input type="text"  class="ReadStyle TxtRight" name="" id="" style="width: 120px;" readonly  value="<%=formBean.getLeadTm()%>">
														</td>
														<td style="width:13%;">
															出庫オーダー：
														</td>
														<td>
															<%
															String delvOdr = "";
															Use2000Bean.PullData[] inputDelvOdrList = formBean.getInputDelvOdrList();
															for (int i = 0; inputDelvOdrList != null && i < inputDelvOdrList.length; i++) {
																Use2000Bean.PullData data = inputDelvOdrList[i];
																if(data.key.equals(formBean.getDelvOdr())){
																	delvOdr = data.value;
																}
															}
															%>
															<input type="text"  class="ReadStyle" name="" id="" style="width: 120px;" readonly  value="<%=delvOdr%>">
														</td>
													</tr>
													<!-- スペース -->
													<tr style="height: 30px;"><td></td></tr>
													<tr>
														<td>
															発生数量：
														</td>
														<td>
															<input type="text"  class="ReadStyle TxtRight" name="orderNum" id="orderNum" style="width: 120px;" readonly  value="<%=formBean.getOrderNum()%>">
														</td>
														<td >
															手配連番：
														</td>
														<td>
															<input type="text"  class="ReadStyle" name="" id="" style="width: 120px;" readonly  value="<%=formBean.getOdrSeq()%>">
														</td>
														<td></td>
														<td></td>
													</tr>
													<!-- スペース -->
													<tr style="height: 30px;"><td></td></tr>
													<tr>
														<td>
															設備機番：
														</td>
														<td colspan="5">
															<%
															String machineNm = "";
															Use2000Bean.PullData[] inputMachineNmList = formBean.getInputMachineNmList();
															for (int i = 0; inputMachineNmList != null && i < inputMachineNmList.length; i++) {
																Use2000Bean.PullData data = inputMachineNmList[i];
																if(data.key.equals(formBean.getMachineNo())){
																	machineNm = data.value;
																}
															}
															%>
															<input type="text"  class="ReadStyle" name="machineNo" id="machineNo" style="width: 420;" value="<%=machineNm%>" readonly>
														</td>
														<td></td>
														<td></td>
														<td></td>
														<td></td>
													</tr>
													<!-- スペース -->
													<tr style="height: 30px;"><td></td></tr>
													<tr>
														<td colspan="2">
															入荷予定年月日：
															<input type="text"  class="ReadStyle" name="" id="" style="width: 120px;" readonly   value="<%=formBean.getArrPlanDt()%>" readonly>
														</td>
														<td >
															入荷年月日：
														</td>
														<td>
															<input type="text"  class="ReadStyle" name="" id="" style="width: 120px;" readonly  value="<%=formBean.getArrDt()%>" readonly>
														</td>
														<td></td>
														<td></td>
													</tr>
												</table>
												<table  border="1" style="width: 400px; height:200px; border-color: gray;" align="left">
													<tr>
														<td>
														<table  border="0" style="width: 98%; height:98%;">
															<tr>
																<td colspan="2">
																	作業完了日
																</td>
															</tr>
															<tr height="10px"><td></td></tr>
															<tr>
																<td class="TxtCenter">
																	作業完了日：
																</td>
																<td class="">
																	<input type="text"  class="ReadStyle TxtRight" name="compDt" id="compDt" style="width: 120px;"  value="<%=formBean.getCompDt()%>" readonly>
																</td>
															</tr>
															<tr>
																<td class="TxtCenter">
																	使用数量：
																</td>
																<td class="">
																	<input type="text"  class="ReadStyle TxtRight" name="" id="" style="width: 120px;" readonly  value="<%=formBean.getUseNum() %>/<%=formBean.getOrderNum()%>">
																</td>
															</tr>
															<tr>
																<td class="TxtCenter">
																	保管場所：
																</td>
																<td class="">
																	<%
																	String strageArea="";
																	Use2000Bean.PullData[] inputStrageArea = formBean.getInputStrageArea();
																	for (int i = 0; inputStrageArea != null && i < inputStrageArea.length; i++) {
																		Use2000Bean.PullData data = inputStrageArea[i];
																		if(data.key.equals(formBean.getStrageArea_hid())){
																			strageArea = data.value;
																		}
																	}
																	%>
																	<input type="text" class="ReadStyle" name="strageArea"  id="strageArea"  style="width:250px;" value="<%=strageArea %>" readonly>
																</td>
															</tr>
														</table>
														</td>
													</tr>
												</table>
											</td>
										</tr>
									</table>

									<!-- スペース -->
									<table height="30px" width="98%"><tr><td></td></tr></table>
									<table height="30px" width="98%" class="borderTop"><tr><td></td></tr></table>

									<table  border="0"  width="98%">
										<tr>
											<td>
												<table border="0" style="margin-left: 30px; width: 98%;">
													<tr>
														<td style="width:10%;">
															発注担当者：
														</td>
														<td>
															<input type="text"  class="ReadStyle" name="" id="" style="width: 120px" readonly  value="<%=formBean.getOdrUsrKumi()%>">
															<input type="text"  class="ReadStyle" name="" id="" style="width: 120px;" readonly  value="<%=formBean.getOdrUsr()%>">
														</td>
														<td></td>
														<td></td>
														<td style="width:7%;">
															使用者：
														</td>
														<td>
															<input type="text"  class="ReadStyle" name="useUsrKey" id="useUsrKey" style="width: 120px;" readonly  value="<%=formBean.getUseUsr()%>">
														</td>
													</tr>
													<!-- スペース -->
													<tr style="height: 30px;"><td></td></tr>
													<tr>
														<td >
															入荷担当者：
														</td>
														<td>
															<input type="text"  class="ReadStyle" name="" id="" style="width: 120px;" readonly  value="<%=formBean.getArrUsrKumi()%>">
															<input type="text"  class="ReadStyle" name="" id="" style="width: 120px;" readonly  value="<%=formBean.getArrUsr()%>">
														</td>
														<td></td>
														<td></td>
														<td></td>
														<td></td>
													</tr>
													<!-- スペース -->
													<tr style="height: 30px;"><td></td></tr>
													<tr>
														<td >
															完了担当者：
														</td>
														<td>
															<input type="text" class="ReadStyle" name="odrUsr"  id="odrUsr"  style="width:120px;" value="<%=formBean.getCompUsrKumi_hid()%>"readonly>
															<input type="text" class="ReadStyle" name="usrList"  id="usrList"  style="width:120px;" value="<%=formBean.getCompUsr_hid()%>" readonly>
														</td>
														<td></td>
														<td></td>
														<td></td>
														<td></td>
													</tr>
												</table>
											</td>
										</tr>
									</table>

									<table  border="0" width="98%">
										<tr>
											<td>
												<table border="0" style=" width: 98%;">
													<tr>
														<td align="right">
															<%if("3".equals(strOutputCate)){ %>
															<input type="image" src="../../common/img/pc/btn_yojo_cancel_off.png" onclick="undoBtn()" alt="余剰取消">
															<%} %>
															&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
															<input type="image" src="../../common/img/pc/btn_back_off.png" onclick="nextPageJump('odr6000')">
														</td>
													</tr>
												</table>
											</td>
										</tr>
									</table>

								</div>
							</div><!-- lc-in End -->


							<!-- ログ Start -->
							<!-- ログ End -->

						</div><!-- lc-out  -->
					</td>
				</tr>
			</table>

			<!--警告 ポップアップ---------------------------------------------------------------------------- -->
			<div id="allbackgr" class="allbackgr" style="display:none;"></div>
			<div class="opAlertBtn" id = "opAlertBtn" style="display:none;" ></div>
			<div class="opAlertButton" id = "opAlertButton" style="display:none;" ></div>
			<div class="opAlertTop" id = "opAlertTop" style="display:none; font-size:22px;">　予備品管理システム　</div>
			<div class="opAlert" id = "opAlert" style="display:none;"></div>
			<!-- -------------------------------------------------------------------------------------------- -->
		
		
			<input type="hidden" id="outputCate" name="outputCate" value="<%=formBean.getOutputCate()%>">
			<input type="hidden" id="nextPage" name="nextPage" value="">
			<input type="hidden" id="usrListKey" name="usrListKey" value="">
			<input type="hidden" id="undoExe" name="undoExe" value="">
			<input type="hidden" id="odrNo" name="odrNo" value="<%=formBean.getOdrNo()%>">
			<input type="hidden" id="updateDt_hid_odr" name="updateDt_hid_odr" value="<%=formBean.getUpdateDt_hid_odr() %>">
			<input type="hidden" id="displayCate" name="displayCate" value="<%=formBean.getDisplayCate() %>">
		</form>
	</body>
</html>
